Skip to content

Conversation

@SarahSoutoul
Copy link
Contributor

@SarahSoutoul SarahSoutoul commented Oct 1, 2025

Description

Fixes https://linear.app/clerk/issue/DOCS-10983/ensure-all-hooks-are-using-typedocs-have-code-examples-for-each.

This PR is part of a broader project aimed at adding more code examples to our hooks documentation. During project discussions, we agreed that the current structure of our hooks docs needed to be revisited. Currently, most of the hook pages are fully rendered through Typedoc, including code examples. However, adding additional examples through Typedoc would have required significant restructuring of the JavaScript repo.

To address this, we decided to:

  • Use Typedoc only for documenting returns and parameters. This is achieved through this PR.
  • Write SDK-specific explanations and code examples directly in the docs instead of generating them via Typedoc. PR on clerk-docs for this: https://github.com/clerk/clerk-docs/pull/2649/files

Additionally, not all hooks currently use Typedoc. This PR also ensures that all hooks are properly configured to use Typedoc for their returns and parameters.

This PR includes:

  • Adding JSDoc comments to the billing hooks so their returns and parameters are correctly pulled from Typedoc.
  • Updating the documentation setup to ensure Typedoc is used only for returns and parameters, not for examples or SDK explanations.

This PR will be the first in a sequence. Once merged, we’ll proceed with its sibling PR in clerk-docs, which:

  • Adds code examples for all supported SDKs.
  • Ensures the updated Typedoc outputs are properly integrated into the docs site.

Hooks checklist

  • Check all the returns render properly for all hooks - can be compared to what's on the live docs (if you'd like a list of all the hooks to check, you can navigate to this PR's description).
  • Check the params render properly for useAuth, useReverification and the billing hooks - can be compared to what's on the live docs.

How to test

In order to test this properly, you will need to do the following:

  • On the javascript repo, switch to the branch of this PR
  • Run pnpm run typedoc:generate
  • Navigate to the clerk-docs repo, and switch to the branch of this PR - ss/DOCS-10983
  • Run npm run typedoc:link ../javascript/.typedoc/docs
  • Now, you can run the docs locally and be able to see the returns and params on each hook, coming through Typedoc.

Important notes/ discussion pts

  • I noticed we use the terminology Parameters for some hooks and for others, we use Properties: We probably want some consistency, so want to open this for discussion.
Screenshot 2025-10-14 at 8 31 46 am Screenshot 2025-10-14 at 8 35 22 am

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Expanded public TypeScript API with additional exported types for payments, checkout, reverification, billing hooks, plans, and subscriptions.
  • Documentation

    • Added JSDoc for new/updated types and generated many reference pages; improved extraction of Parameters/Returns for API docs.
  • Chores

    • Updated doc-generation scripts/workflow to extract sections and reorganize generated docs; included a changeset for minor version bumps.

@vercel
Copy link

vercel bot commented Oct 1, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Nov 7, 2025 7:27pm

@changeset-bot
Copy link

changeset-bot bot commented Oct 1, 2025

🦋 Changeset detected

Latest commit: f5a92f9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
@clerk/shared Minor
@clerk/types Minor
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/chrome-extension Patch
@clerk/clerk-js Patch
@clerk/elements Patch
@clerk/expo-passkeys Patch
@clerk/clerk-expo Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/clerk-react Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/themes Patch
@clerk/vue Patch
@clerk/localizations Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 1, 2025

Walkthrough

Exports and documents multiple previously internal TypeScript types across React hooks and components, adds JSDoc comments, introduces a Typedoc extraction script that splits "Returns" and "Parameters" sections into separate MDX files, updates Typedoc entry points and link mappings, and integrates the extraction step into the docs generation script. No runtime behavior changes.

Changes

Cohort / File(s) Summary
Commerce API Types
packages/shared/src/react/commerce.tsx
Exported PaymentElementProviderProps, PaymentElementProps, and UsePaymentElementReturn; added JSDoc and updated PaymentElement props to use PaymentElementProps. No runtime changes.
Checkout & Hooks Types
packages/shared/src/react/contexts.tsx, packages/shared/src/react/hooks/useCheckout.ts, packages/shared/src/react/hooks/useReverification.ts, packages/shared/src/react/hooks/createBillingPaginatedHook.tsx, packages/shared/src/react/hooks/usePlans.tsx
Promoted several internal types to public exports (e.g., UseCheckoutOptions, UseCheckoutReturn, UseCheckoutParams alias, NeedsReverificationParameters, UseReverificationOptions, exported HookParams, UsePlansReturn), added JSDoc, and updated signatures/type refs to reference exported types.
Documentation Comments
packages/shared/src/react/hooks/useSubscription.types.ts, packages/shared/src/errors/clerkApiResponseError.ts
Added/expanded JSDoc for subscription-related types and ClerkAPIResponseError. Only comments added.
Typedoc Extraction & Config
.typedoc/extract-returns-and-params.mjs, .typedoc/custom-plugin.mjs, package.json, packages/shared/typedoc.json
Added MDX extraction script to produce -return.mdx and -params.mdx files, updated custom-plugin file lists and link replacements, invoked extraction in typedoc:generate:skip-build, replaced post-gen move with rimraf/cpy sequence, and extended TypeDoc entryPoints.
Changeset / Release Metadata
.changeset/violet-boxes-watch.md
Added changeset noting minor bumps and Typedoc/hooks documentation work.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant TD as TypeDoc
    participant Script as extract-returns-and-params.mjs
    participant FS as Filesystem (MDX)
    participant Final as Final docs (.typedoc/docs)

    TD->>FS: generate initial MDX files
    TD->>Script: invoke extraction script
    Script->>FS: scan MDX files (exclude -return|-params|-props)
    alt "## Returns" found
        Script->>Script: extract Returns section
        Script->>FS: write <file>-return.mdx
    end
    alt "## Parameters" found
        Script->>Script: extract Parameters section
        Script->>Script: replace generic param table patterns
        Script->>FS: write <file>-params.mdx
        Script->>FS: remove stale -props.mdx (if present)
    end
    Script->>TD: log counts
    TD->>Final: assemble final docs (cpy & cleanup)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Focus areas:
    • .typedoc/extract-returns-and-params.mjs — parsing edge cases, regex robustness, file deletion safety.
    • packages/shared/src/react/hooks/useCheckout.ts — validate UseCheckoutReturn shape and downstream consumers.
    • packages/shared/typedoc.json and .typedoc/custom-plugin.mjs — ensure no unintended symbol exposure or broken links.
    • package.json script changes — ordering and correctness of rimraf/cpy steps.

Suggested labels

types, react

Poem

🐰
I hopped through types both brave and bright,
Carved Returns and Params into separate light,
A tiny script chewed lines in two,
Docs now tidy — examples queue! 🎉

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: generating params and return types documentation for hooks using Typedoc, which aligns with the core changeset focus.
Linked Issues check ✅ Passed The PR addresses DOCS-10983 by ensuring hooks expose typed metadata via Typedoc (params/returns), adding JSDoc comments for Typedoc extraction, and standardizing hook configuration for documentation generation.
Out of Scope Changes check ✅ Passed All changes are scoped to DOCS-10983 objectives: exporting hook types, adding JSDoc documentation, updating Typedoc configuration, and refactoring documentation extraction scripts to generate params and returns.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ss/DOCS-10983

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9e58a57 and f5a92f9.

📒 Files selected for processing (1)
  • .typedoc/extract-returns-and-params.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .typedoc/extract-returns-and-params.mjs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (30)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Static analysis
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@SarahSoutoul SarahSoutoul changed the title Refactor Typedoc for hooks to support hook code examples on Clerk docs docs(repo): Refactor Typedoc for hooks to support hook code examples on Clerk docs Oct 1, 2025
@SarahSoutoul SarahSoutoul self-assigned this Oct 1, 2025
@SarahSoutoul SarahSoutoul changed the title docs(repo): Refactor Typedoc for hooks to support hook code examples on Clerk docs docs(repo): Generate all function params and return types Oct 2, 2025
@SarahSoutoul SarahSoutoul changed the title docs(repo): Generate all function params and return types docs(repo): Generate all params and return types (hooks work) Oct 2, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/shared/src/react/hooks/useReverification.ts (1)

14-16: Remove empty JSDoc comment.

This empty JSDoc block adds no value. Per past review feedback, these were marked for cleanup but remain in the code.

Apply this diff:

-/**
- *
- */
 async function resolveResult<T>(result: Promise<T> | T): Promise<T | ReturnType<typeof reverificationError>> {
♻️ Duplicate comments (1)
packages/shared/src/react/hooks/useReverification.ts (1)

101-107: Remove empty JSDoc comments.

Multiple empty JSDoc blocks (lines 101-103, 105-107) add no value. Per past review feedback, these were marked for cleanup but remain in the code.

Apply this diff:

-/**
- *
- */
 function createReverificationHandler(params: CreateReverificationHandlerParams) {
-  /**
-   *
-   */
   function assertReverification<Fetcher extends (...args: any[]) => Promise<any> | undefined>(
🧹 Nitpick comments (1)
packages/shared/src/react/hooks/useReverification.ts (1)

40-53: Consider readonly and optional property syntax for type safety.

The JSDoc documentation is accurate. For improved type safety and TypeScript best practices:

  • Mark callback fields as readonly to prevent reassignment
  • Use optional syntax level?: SessionVerificationLevel instead of | undefined for clarity

Apply this diff:

 export type NeedsReverificationParameters = {
   /**
    * Marks the reverification process as cancelled and rejects the original request.
    */
-  cancel: () => void;
+  readonly cancel: () => void;
   /**
    * Marks the reverification process as complete and retries the original request.
    */
-  complete: () => void;
+  readonly complete: () => void;
   /**
    * The verification level required for the reverification process.
    */
-  level: SessionVerificationLevel | undefined;
+  readonly level?: SessionVerificationLevel;
 };
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b6e0a0e and 7c7ddb6.

📒 Files selected for processing (2)
  • packages/shared/src/react/hooks/useReverification.ts (3 hunks)
  • packages/shared/src/react/hooks/useSubscription.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/shared/src/react/hooks/useSubscription.tsx
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/shared/src/react/hooks/useReverification.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/shared/src/react/hooks/useReverification.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/shared/src/react/hooks/useReverification.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/shared/src/react/hooks/useReverification.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/shared/src/react/hooks/useReverification.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/shared/src/react/hooks/useReverification.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (2)
packages/shared/src/react/hooks/useReverification.ts (2)

60-70: LGTM!

The JSDoc documentation for UseReverificationOptions correctly describes the properties object with nested parameter documentation. This should generate accurate TypeDoc output.


82-94: Inline JSDoc is clear and the | undefined constraint is correct.

The | undefined in the Fetcher constraint intentionally allows fetchers whose return types can be Promise<X> | undefined due to optional chaining (e.g., () => user?.createTOTP()). This pattern is used throughout the codebase. The resolveResult function properly handles undefined returns since it accepts Promise<T> | T. The inline JSDoc for both parameters is clear and follows the established documentation style.

@SarahSoutoul
Copy link
Contributor Author

Blocked for now as waiting for this to go out: clerk/clerk-docs#2756

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/shared/src/react/hooks/useSubscription.types.ts (1)

3-19: LGTM! Clear and complete parameter documentation.

The JSDoc documentation for UseSubscriptionParams is well-structured with accurate field descriptions and properly specified default values. This will generate excellent TypeDoc output for developers.

Optional enhancement: Consider adding a brief description of the type itself before the @interface tag to provide additional context in the generated documentation:

 /**
+ * Configuration options for the useSubscription hook.
+ *
  * @interface
  */
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7c7ddb6 and 7389079.

📒 Files selected for processing (3)
  • .typedoc/custom-plugin.mjs (3 hunks)
  • packages/shared/src/react/contexts.tsx (1 hunks)
  • packages/shared/src/react/hooks/useSubscription.types.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • .typedoc/custom-plugin.mjs
  • packages/shared/src/react/contexts.tsx
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/shared/src/react/hooks/useSubscription.types.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/shared/src/react/hooks/useSubscription.types.ts
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/shared/src/react/hooks/useSubscription.types.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/shared/src/react/hooks/useSubscription.types.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/shared/src/react/hooks/useSubscription.types.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/shared/src/react/hooks/useSubscription.types.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (1)
packages/shared/src/react/hooks/useSubscription.types.ts (1)

21-45: Excellent return type documentation with clear field descriptions.

The JSDoc for SubscriptionResult<TData> provides comprehensive documentation for each field:

  • The data field clearly describes all three possible states
  • The error field correctly uses unknown type per coding guidelines
  • The distinction between isLoading and isFetching is well-explained
  • The updated revalidate description is more precise and developer-friendly

The return type Promise<void> | void for revalidate appropriately handles both synchronous and asynchronous execution patterns.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
.typedoc/extract-returns-and-params.mjs (2)

14-45: Consider extracting magic numbers for clarity.

The logic correctly extracts the Returns section and writes it alongside the source file. However, the magic number 10 at line 25 (and 13 at line 91) represents the length of the heading strings and could be made clearer.

 function extractReturnsSection(filePath) {
   const content = fs.readFileSync(filePath, 'utf-8');
 
+  const returnsHeading = '## Returns';
   // Find the "## Returns" section
-  const returnsStart = content.indexOf('## Returns');
+  const returnsStart = content.indexOf(returnsHeading);
 
   if (returnsStart === -1) {
     return false; // No Returns section found
   }
 
   // Find the next heading after "## Returns" (or end of file)
-  const afterReturns = content.slice(returnsStart + 10); // Skip past "## Returns"
+  const afterReturns = content.slice(returnsStart + returnsHeading.length);

Apply a similar pattern to extractParametersSection at line 91.


52-59: Consider making type replacements configurable.

The function hardcodes a single type expansion for Fetcher. If additional types require similar expansion in the future, this approach will require code changes for each new type.

Consider using a configuration map:

const TYPE_REPLACEMENTS = {
  'Fetcher': 'Fetcher extends (...args: any[]) => Promise<any>',
  // Add more types here as needed
};

function replaceGenericTypesInParamsTable(content) {
  let result = content;
  for (const [shortType, expandedType] of Object.entries(TYPE_REPLACEMENTS)) {
    const pattern = new RegExp(`(\\|\\s*\`\\w+\`\\s*\\|\\s*)\`${shortType}\`(\\s*\\|)`, 'g');
    result = result.replace(pattern, `$1\`${expandedType}\`$2`);
  }
  return result;
}
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 4e09572 and 5932883.

📒 Files selected for processing (1)
  • .typedoc/extract-returns-and-params.mjs (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (3)
.typedoc/extract-returns-and-params.mjs (3)

1-8: LGTM!

The ESM setup with TypeScript checking and standard Node.js imports is appropriate for this build script.


117-143: LGTM!

The recursive file collection correctly filters out generated files and handles missing directories gracefully.


148-150: Verify single-package scope is intentional.

The script currently processes only clerk-react, though the loop structure supports multiple packages. Confirm this limitation aligns with the PR's current scope.

If additional packages need Returns/Parameters extraction in the future, simply add them to the array:

const packages = ['clerk-react', 'clerk-nextjs', ...];

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/shared/src/types/clerk.ts (1)

82-84: LGTM! Inline annotation added for Typedoc processing.

The @inline annotation is appropriate here and consistent with similar types in this file (e.g., SDKMetadata, SignOut, ClerkStatus). This will help Typedoc inline the CheckoutResult type definition where it's referenced in the experimental checkout API.

Optionally, consider adding a brief description to clarify the type's purpose:

 /**
+ * Result of a checkout operation, either successful with data or failed with an error.
+ *
  * @inline
  */

This would match the documentation pattern used for other @inline types like SDKMetadata and RouterFn.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5932883 and 9e58a57.

📒 Files selected for processing (3)
  • .typedoc/custom-plugin.mjs (3 hunks)
  • packages/shared/src/types/clerk.ts (1 hunks)
  • packages/shared/typedoc.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • packages/shared/src/types/clerk.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • packages/shared/src/types/clerk.ts
  • packages/shared/typedoc.json
packages/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

TypeScript is required for all packages

Files:

  • packages/shared/src/types/clerk.ts
packages/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Packages should export TypeScript types alongside runtime code

Files:

  • packages/shared/src/types/clerk.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • packages/shared/src/types/clerk.ts
**/*.{js,ts,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • packages/shared/src/types/clerk.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Build Packages
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (4)
packages/shared/typedoc.json (1)

3-10: Entry points verified—no changes needed.

Both new Typedoc entry points exist and export the expected types (PaymentElementProviderProps, PaymentElementProps, UsePaymentElementReturn, and UseCheckoutOptions), confirming the configuration properly exposes payment and checkout types for documentation generation.

.typedoc/custom-plugin.mjs (3)

21-35: LGTM! Past issues resolved.

The additions to FILES_WITHOUT_HEADINGS look good. I can confirm:

  • The typo in use-reverification-params.mdx (line 33) has been fixed—it now correctly uses .mdx instead of ,mdx
  • The duplicate use-payment-element-return.mdx has been removed
  • All 15 new entries follow the consistent naming pattern

46-47: LGTM! New link replacements are well-formed.

The new LINK_REPLACEMENTS entries follow the established patterns:

  • Anchor links (#...) for same-page sections (lines 46-47)
  • Full documentation paths for billing resources (lines 81-82, 86-88)
  • Hook return documentation with anchor (line 92)

All paths are consistent with the existing URL structure.

Also applies to: 81-82, 86-88, 92-92


8-36: ****

The original review comment incorrectly assumes that all files in FILES_WITHOUT_HEADINGS require corresponding LINK_REPLACEMENTS entries. However, verification shows this is not the case.

LINK_REPLACEMENTS is a temporary solution for replacing relative links that point TO these files from other MDX documentation. The search results confirm that none of the 12 files without mappings are cross-referenced anywhere in the .typedoc/ directory—they only appear in the FILES_WITHOUT_HEADINGS array itself. Therefore, missing entries in LINK_REPLACEMENTS do not create broken links. The code is functioning as intended.

Likely an incorrect or invalid review comment.

@blacksmith-sh

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants